package com.onstar.cn.vehicle.receive;


import com.onstar.cn.common.log.LogManager;
import com.onstar.cn.vehicle.result.IResultService;
import com.onstar.cn.vehicle.result.PollingResult;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * 
* @ClassName: BrocastReceiveFactory 
* @Description: 需要在发送polling的activity注册此类
* @author 6335yz
* @date 2015年8月28日 上午10:24:33
 */
public class BrocastReceiveFactory extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
//		if(intent.getSerializableExtra("pollingResult") != null) {
//			PollingResult result = (PollingResult) intent.getSerializableExtra("pollingResult");
//			Class<?> clazz = context.getClass();
//			try {
//				Method method = clazz.getMethod(Constants.CALL_BACK_METHOD, PollingResult.class);
//				method.invoke(context, result);
//			} catch (NoSuchMethodException e) {
//				e.printStackTrace();
//			} catch (IllegalAccessException e) {
//				e.printStackTrace();
//			} catch (IllegalArgumentException e) {
//				e.printStackTrace();
//			} catch (InvocationTargetException e) {
//				e.printStackTrace();
//			}
//		}
		if(intent.getSerializableExtra("pollingResult") != null) {
			PollingResult result = (PollingResult) intent.getSerializableExtra("pollingResult");
			IResultService resultService = (IResultService)context;
			resultService.onResult(result);
		}
	}
}
